package com.gzbit.calculator.simplefactory.factory;

import com.gzbit.calculator.simplefactory.bll.AddOperation;
import com.gzbit.calculator.simplefactory.bll.MulOperation;
import com.gzbit.calculator.simplefactory.bll.Operation;
import com.gzbit.calculator.simplefactory.bll.SubOperation;

//简单工厂类
public class SimpleFactory {
    /*
     * 根据运算符号确定实例化哪个运算类对象(“生产运算类对象”)
     * */
    public static Operation getOperation(String operator) {
        Operation operation=null;
        switch (operator) {
            case "+":
                operation = new AddOperation();
                break;
            case "-":
                operation = new SubOperation();
                break;
            case "*":
                operation = new MulOperation();
                break;
            default:
                operation = null;
        }
        return operation;
    }
}
